import axios from 'axios'
import React,{useEffect,useState} from 'react'
import Swiper from '../components/Swiper'
import Header from '../components/Header'
/**
 * 1、页面组件获取后端数据
 */
export default function Home() {
  useEffect(()=>{
    getSwiper()
  },[])
  const [swiperdata,setSwiperData]=useState([])
  const getSwiper=async()=>{
    let result=await axios.get('https://www.fastmock.site/mock/69a124679b4578ec8eed383a276c670b/w10/api/getSwiper')
    setSwiperData(result.data)
  }
  return (
    <div>
       <div>
          <Header></Header>
       </div>
       <div>
          {swiperdata.length>0?<Swiper swiperdata={swiperdata}></Swiper>:<></>}
       </div>
    </div>
  )
}
